package com.liuceng.peatio

import com.liuceng.BaseSpec
import com.liuceng.peatio.service.FrontAdGroupService
import org.springframework.beans.factory.annotation.Autowired

import java.math.RoundingMode

import static spock.util.matcher.HamcrestMatchers.closeTo
import static spock.util.matcher.HamcrestSupport.that

/**
 * Created by liyuhang on 2016-13-11.
 */
class TestSpec extends BaseSpec {
    def "测试除不尽的时候BigDecimal的处理"() {
        given:
        BigDecimal a = new BigDecimal(1 / 3.0)
        BigDecimal b = new BigDecimal(1).divide(new BigDecimal(3), 2, RoundingMode.CEILING.HALF_DOWN)

        expect:
        that a, closeTo(0, 0.4)
        that b, closeTo(0, 0.4)
        [1, 2, 3].sum() == 6
    }
}